package Thread;

/**
 *
 */
public class BuyTicket implements Runnable{

    private int ticketNum = 10;


    @Override
    public void run() {
        while(ticketNum > 0){

            try {
                Thread.sleep(300);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            System.out.println(Thread.currentThread().getName()+"拿到了"+ticketNum--+"张票");

        }
    }

    public static void main(String[] args) {
        BuyTicket buyTicket = new BuyTicket();

        new Thread(buyTicket,"小明").start();
        new Thread(buyTicket,"老师").start();
        new Thread(buyTicket,"黄牛").start();

    }

}
